package com.android.lovingpet.home.view;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import com.android.lovingpet.R;
import com.android.lovingpet.util.LocationClient;
import com.android.lovingpet.util.Utility;
import com.chaychan.library.BottomBarLayout;


public class HomeActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);

        ViewPager viewPager = findViewById(R.id.pagers_home);
        viewPager.setOffscreenPageLimit(4);
        BottomBarLayout barLayout = findViewById(R.id.bottom_bar);
        viewPager.setAdapter(new HomeAdapter(getSupportFragmentManager()));
        barLayout.setViewPager(viewPager);

        Utility.openLocationPermission(this);
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (requestCode==1)
        {
            //获取位置信息
            LocationClient.getLocation(null);
        }
    }
}
